exports.replaceSqlField = function (sql_obj, param_obj) {
    for (var key in param_obj) {
        if (key && param_obj[key] || param_obj[key] == '') {
            var k_db = "<" + key.trim() + ">";
            var k_in = "[" + key.trim() + "]";
            sql_obj = replace_string(sql_obj, k_in, param_obj[key]);
            sql_obj = replace_string(sql_obj, k_db, param_obj[key]);
        } else {
            console.log("replaceSqlField[params is wrong!]")
        }
    }
    return sql_obj;
}



function replace_string(sql_temp, key, val) {
    if (sql_temp == null || key == null)
        return sql_temp;

    if ('string' == typeof val) {
        val = val.trim();
        if (val != null) val =
            val.replace(/'/g, "\\'");
    }
    while (sql_temp.indexOf(key, 0) > 0) {
        sql_temp = sql_temp.replace(key, val);
    }
    return sql_temp;
}

